/*
 * 软件版权: 恒生电子股份有限公司
 * 修改记录:
 * 修改日期     修改人员  修改说明
 * ========    =======  ============================================
 * 2021/4/9  lisy31662  新增
 * ========    =======  ============================================
 */
package com.sansi.pencilbook.mapper;

import com.sansi.pencilbook.entity.AmtJournal;
import org.apache.ibatis.annotations.*;

import java.sql.SQLException;
import java.util.List;

/**
 * 功能说明: 资金流水表的增删改查
 *
 * @author lisy31662
 */
@Mapper
public interface AmtJournalMapper {

  @Insert("insert into amt_journal (user_id, amt, type, counterparty, time) value (#{userId}, #{type}, #{counterparty}, #{time})")
  public int saveAmtJournal(AmtJournal amtJournal) throws SQLException;

  @Select("select journal_id, user_id, amt, type, counterparty, time from amt_journal")
  public List<AmtJournal> findAmtJournalAll() throws SQLException;

  @Select("select journal_id, user_id, amt, type, counterparty, time where user_id=#{userId}")
  public List<AmtJournal> findAmtJournalByUser(int userId) throws SQLException;

  @Select("select journal_id, user_id, amt, type, counterparty, time where user_id=#{userId} and type=#{type}")
  public List<AmtJournal> findAmtJournalByUserType(int userId, String type) throws SQLException;

  @Select("select journal_id, user_id, amt, type, counterparty, time where type=#{type}")
  public List<AmtJournal> findAmtJournalByType(String type) throws SQLException;

  @Select("select journal_id, user_id, amt, type, counterparty, time where journal_id=#{journalId}")
  public AmtJournal findAmtJournalById(int journalId) throws SQLException;

  @Update("update amt_journal set amt=#{amt} where journal_id=#{journalId}")
  public int updateAmtJournal(AmtJournal amtJournal) throws SQLException;

  @Delete("delete from amt_journal where journal_id=#{journalId}")
  public int deleteAmtJournal(AmtJournal amtJournal) throws SQLException;

}
